package com.zx.map.dao.impl;

import com.zx.map.dao.MerchantOfflineConfigInfoDao;
import com.zx.map.dao.mapper.MerchantOfflineConfigInfoMapper;
import com.zx.map.dao.model.MerchantOfflineConfigInfo;
import com.zx.map.dao.model.MerchantOfflineConfigInfoExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: ������
 * Date: 15-5-12
 * Time: ����14:12
 * ������Ϣ�����ݲ���-ʵ��
 */
@Component("merchantOfflineConfigInfoDao")
public class MerchantOfflineConfigInfoImpl implements MerchantOfflineConfigInfoDao {

    @Autowired
    private MerchantOfflineConfigInfoMapper mapper;

    /**
     * 新增
     */
    public String add(MerchantOfflineConfigInfo merchantOfflineConfigInfo) throws DataAccessException {
        int column = mapper.insert(merchantOfflineConfigInfo);
        if (column != 1) {
            throw new RuntimeException("");
        }
        return merchantOfflineConfigInfo.getMerchantId();
    }

    /**
     * 修改
     *
     * @param merchantOfflineConfigInfo
     * @return
     * @throws DataAccessException
     */
    public String update(MerchantOfflineConfigInfo merchantOfflineConfigInfo) throws DataAccessException {
        int column = mapper.updateByPrimaryKeySelective(merchantOfflineConfigInfo);
        if (column != 1) {
            throw new RuntimeException("");
        }
        return merchantOfflineConfigInfo.getMerchantId();
    }

    /**
     * 删除
     */
    public void delete(MerchantOfflineConfigInfo merchantOfflineConfigInfo) throws DataAccessException {
        int column = mapper.deleteByPrimaryKey(merchantOfflineConfigInfo.getMerchantId());
        if (column != 1) {
            throw new RuntimeException("");
        }
    }

    @Override
    public List<MerchantOfflineConfigInfo> getPageByExample(int pageSize, int pageBegin, MerchantOfflineConfigInfoExample example) throws DataAccessException {
        return null;
    }


    /**
     * 查找条数
     *
     * @param example
     * @return
     * @throws DataAccessException
     */
    public int countByExample(MerchantOfflineConfigInfoExample example) throws DataAccessException {
        return mapper.countByExample(example);
    }

    /**
     *
     */
    public List<MerchantOfflineConfigInfo> getListByExample(MerchantOfflineConfigInfoExample example)
            throws DataAccessException {
        return mapper.selectByExample(example);
    }

    public MerchantOfflineConfigInfo selectByPrimaryKey(String key) throws DataAccessException {
        return mapper.selectByPrimaryKey(key);
    }

}
